﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZHello.GDI
{
    public class DrawBezierUnit
    {
        /*
         贝塞尔曲线.md
         */

        public static void DrawBezierRect(Graphics g, Rectangle rect)
        {

        }

        public static void DrawBezier(Graphics g)
        {
            var pfs = new PointF[]
            {
                new PointF(100,100),//起始点
                new PointF(100,150),//控制点1
                new PointF(100,150),//控制点1
                new PointF(150,150),//结束点
            };
            using (var p = new Pen(Color.Red, 3))
            {
                g.DrawStar(new PointF(150, 100), Color.Blue);
                g.DrawEllipse(Pens.Green, new Rectangle(100, 50, 100, 100));
                g.DrawBezier(p, pfs[0], pfs[1], pfs[2], pfs[3]);
            }
        }

        public static void DrawBeziers(Graphics g)
        {
            //数组中的点数应为 3 的倍数加 1，如 4、7 或 10
            var pfs = new PointF[]
            {
                new PointF(300,300),

                new PointF(350,350),
                new PointF(350,350),
                new PointF(300,400),

                new PointF(350,350),
                new PointF(350,350),
                new PointF(400,400),

                new PointF(350,350),
                new PointF(350,350),
                new PointF(400,300),

                new PointF(350,350),
                new PointF(350,350),
                new PointF(300,300),
                //
                new PointF(250,350),
                new PointF(250,350),
                new PointF(300,400),

                new PointF(350,450),
                new PointF(350,450),
                new PointF(400,400),

                new PointF(450,350),
                new PointF(450,350),
                new PointF(400,300),

                new PointF(350,250),
                new PointF(350,250),
                new PointF(300,300),
            };
            g.DrawBeziers(Pens.Red, pfs);
            g.DrawEllipse(Pens.Green, new Rectangle(250, 250, 200, 200));
            g.DrawEllipse(Pens.Blue, new Rectangle(300, 300, 100, 100));
            g.DrawRectangle(Pens.Blue, new Rectangle(300, 300, 100, 100));
            g.DrawLines(Pens.Orange, 
                new PointF[] { 
                    new PointF(250, 350), 
                    new PointF(350, 450), 
                    new PointF(450, 350), 
                    new PointF(350, 250), 
                    new PointF(250, 350), });
        }
    }
}
